<#assign className = table.className>
<#assign classNameLower = table.classNameLower><#if  '${subpackage}'=="">
package ${basepackage}.controller;
<#else>
package ${basepackage}.${subpackage}.controller;
</#if>

import com.yr.dj.sys.intf.feignclients.BaseSystemClient;
import ${basepackage}.${subpackage}.intf.${feignPackage}.${className}Client;
import com.yr.dj.util.ApiUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.github.pagehelper.PageInfo;
import com.yr.dj.util.ApiResult;
import com.yr.dj.util.dt.PageQuery;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import ${basepackage}.${subpackage}.intf.entity.${className};

import java.security.Principal;

<#include "java_copyright.include">

@RestController
@RequestMapping("/${table.sqlName}_ui")
@Api(value = "${className}UIController", description = "${table.tableRemark}")
public class ${className}UIController  {

    @Autowired
	private ${className}Client ${classNameLower}Client;

    @Autowired
    BaseSystemClient baseSystemClient;

    @PostMapping("/save_or_update")
    @ApiOperation("新增或者更新")
    public ApiResult<Boolean> saveOrUpdate(@RequestBody ${className} ${classNameLower},Principal principal){
        return ApiUtil.getResult(${classNameLower}Client.saveOrUpdate(${classNameLower}
                        ,baseSystemClient.get_user(principal.getName()).getId()));
	}

    @PostMapping("/delete")
    @ApiOperation("删除数据")
    public ApiResult<Boolean>  delete(@RequestParam("id") Integer id){
        return ApiUtil.getResult(${classNameLower}Client.delete(id));
    }

    @PostMapping("/load_by_search")
    @ApiOperation("获取列表")
    public ApiResult<PageInfo<${className}>>loadBySearch(@RequestBody PageQuery query){
        return ApiUtil.getResult(${classNameLower}Client.loadBySearch(query));
    }
}

